<?php

namespace App\Filament\Resources\OrderResource\Widgets;

use App\Enums\OrderStatus;
use App\Models\Order;
use Carbon\Carbon;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class OrderOverview extends BaseWidget
{
    protected function getStats(): array
    {
        return [
            Stat::make('累计交易金额', Order::where('status',OrderStatus::HAS_COMPLETE)->sum('price'))->color('success'),
            Stat::make('今日交易额', Order::query()->whereDate('created_at',Carbon::today())->sum('price')),
            Stat::make('待支付金额', Order::where('status',OrderStatus::NO_PAY)->sum('price'))->color('danger'),
        ];
    }
}
